Fix iopl() syscall so that we pass LTP's iopl02 test.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 4 Aug 2005 13:13:02 +0000 (13:13 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 4 Aug 2005 13:13:02 +0000 (13:13 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c
linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c

index 3aa6c5a4cfb9909b57593fb0452c9c4585b0437f..314033ce415e747ce152bb0bab4563b1adfcd8e8 100644 (file)
@@ -113,16 +113,12 @@ asmlinkage long sys_iopl(unsigned int new_io_pl)
        if ((new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO))
                return -EPERM;
 
-       /* Maintain OS privileges even if user attempts to relinquish them. */
-       if (new_io_pl == 0)
-               new_io_pl = 1;
-
        /* Change our version of the privilege levels. */
        current->thread.io_pl = new_io_pl;
 
        /* Force the change at ring 0. */
        op.cmd             = PHYSDEVOP_SET_IOPL;
-       op.u.set_iopl.iopl = new_io_pl;
+       op.u.set_iopl.iopl = (new_io_pl == 0) ? 1 : new_io_pl;
        HYPERVISOR_physdev_op(&op);
 
        return 0;
index 6cc2be645087b8e907555c6b2a6642f095677d4b..76e5d04801b3dd75f6e0f777b4deb6d814b6dda8 100644 (file)
@@ -539,7 +539,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
 
        if (unlikely(prev->io_pl != next->io_pl)) {
                iopl_op.cmd             = PHYSDEVOP_SET_IOPL;
-               iopl_op.u.set_iopl.iopl = next->io_pl;
+               iopl_op.u.set_iopl.iopl = (next->io_pl == 0) ? 1 : next->io_pl;
                mcl->op      = __HYPERVISOR_physdev_op;
                mcl->args[0] = (unsigned long)&iopl_op;
                mcl++;
index 50e0cf52e187b82e012fd829a60ac3896a02cccc..93b97453868db747e8fc2b084fe5f4bd2a62240f 100644 (file)
@@ -1636,7 +1636,7 @@ void __init setup_arch(char **cmdline_p)
                efi_map_memmap();
 
        op.cmd             = PHYSDEVOP_SET_IOPL;
-       op.u.set_iopl.iopl = current->thread.io_pl = 1;
+       op.u.set_iopl.iopl = 1;
        HYPERVISOR_physdev_op(&op);
 
 #ifdef CONFIG_ACPI_BOOT
index 1b3d1c7e6f24c64e182fdd4af7c7bcb208857df6..e75b424aa81c86442cda5200d89806281de0d68a 100644 (file)
@@ -880,7 +880,8 @@ static int __init do_boot_cpu(int apicid)
        ctxt.user_regs.cs = __KERNEL_CS;
        ctxt.user_regs.eip = start_eip;
        ctxt.user_regs.esp = idle->thread.esp;
-       ctxt.user_regs.eflags = (1<<9) | (1<<2) | (idle->thread.io_pl<<12);
+#define X86_EFLAGS_IOPL_RING1 0x1000
+       ctxt.user_regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_IOPL_RING1;
 
        /* FPU is set up to default initial state. */
        memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
index 7d7385cf61bb937bf7addadf3afcfc9cb90cced7..08ccd0f79d759da0f891c9e00716995b00cb0a35 100644 (file)
@@ -30,7 +30,6 @@ asmlinkage long sys_iopl(unsigned int new_io_pl, struct pt_regs *regs)
         unsigned int old_io_pl = current->thread.io_pl;
         physdev_op_t op;
 
-
        if (new_io_pl > 3)
                return -EINVAL;
 
@@ -38,16 +37,12 @@ asmlinkage long sys_iopl(unsigned int new_io_pl, struct pt_regs *regs)
        if ((new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO))
                return -EPERM;
 
-       /* Maintain OS privileges even if user attempts to relinquish them. */
-       if (new_io_pl == 0)
-               new_io_pl = 1;
-
        /* Change our version of the privilege levels. */
        current->thread.io_pl = new_io_pl;
 
        /* Force the change at ring 0. */
        op.cmd             = PHYSDEVOP_SET_IOPL;
-       op.u.set_iopl.iopl = new_io_pl;
+       op.u.set_iopl.iopl = (new_io_pl == 0) ? 1 : new_io_pl;
        HYPERVISOR_physdev_op(&op);
 
        return 0;
index a6b1a843cffccf83109efec2e6f5c5e8c666fc24..f19ff9b94b90f48749ff27b415569cbbb33865df 100644 (file)
@@ -465,7 +465,7 @@ struct task_struct *__switch_to(struct task_struct *prev_p, struct task_struct *
 
        if (unlikely(prev->io_pl != next->io_pl)) {
                iopl_op.cmd             = PHYSDEVOP_SET_IOPL;
-               iopl_op.u.set_iopl.iopl = next->io_pl;
+               iopl_op.u.set_iopl.iopl = (next->io_pl == 0) ? 1 : next->io_pl;
                mcl->op      = __HYPERVISOR_physdev_op;
                mcl->args[0] = (unsigned long)&iopl_op;
                mcl++;
index 080121e1ab54e3c7d5a4aab09592c06791998e08..0a5a202651796e0a8629f088011e0920915b64af 100644 (file)
@@ -824,7 +824,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
 
        op.cmd             = PHYSDEVOP_SET_IOPL;
-       op.u.set_iopl.iopl = current->thread.io_pl = 1;
+       op.u.set_iopl.iopl = 1;
        HYPERVISOR_physdev_op(&op);
 
        if (xen_start_info.flags & SIF_INITDOMAIN) {